<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
  <title>Rugby for Trac</title>
<link rel="stylesheet" type="text/css" href="/stylesheets/main.css" />
  <%= stylesheet_link_tag 'consolidated', :media => 'all' %>
  <%= stylesheet_link_tag 'ajax_scaffold', :media => 'all' %>
  <%= javascript_include_tag :defaults %>
  <%= javascript_include_tag 'rico_corner', 'ajax_scaffold' %>
  
  <%= stylesheet_link_tag 'date-picker', :media => 'all' %>
  <%= javascript_include_tag 'date-picker' %>
  <style type="text/css" media="screen">

  #header-right {
    
  padding: 0px;
  margin: 10px;
  font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
    font-size: 11px;
    clear: both;
 
  }
  
  #calender {
     background-color: #ffd;
     border: 1px solid #fc0;
     margin-left:  0px;
   margin-right: 0px;
   }
   #calender table {
     
     margin: 0px;
     padding: 1px 1px 1px 1px;
     font-size: 8px;
     border-collapse: collapse;
   }
   
   #calender td.day {
     padding: 4px;
   }
   #calender td.sprint_active  {
     padding: 4px;
     background-color: #ffa;
   }

   #calender td.sprint_today  {
     padding: 4px;
     background-color: #ddd;
   }

  
  #about-content {
       background-color: #ffd;
       border: 1px solid #fc0;
       margin-left:  11px;
	   margin-right: 11px;
     }
     #about-content table {
       margin-top: 10px;
       margin-bottom: 10px;
       font-size: 11px;
       border-collapse: collapse;
     }
     #about-content td {
       padding: 10px;
       padding-top: 3px;
       padding-bottom: 3px;
     }
     #about-content td.name  {color: #555}
     #about-content td.value {color: #000}
     
     #about-content.failure {
       background-color: #fcc;
       border: 1px solid #f00;
     }
     #about-content.failure p {
       margin: 0;
       padding: 10px;
     }

     #sidebar {
       float: left;
       width: 200px;
	   padding: 0px;
	   margin: 0px;
	   font-family: "Lucida Grande", "Bitstream Vera Sans", "Verdana";
       font-size: 11px;
	  
     }
     
	 #sidebar ul {
       margin-left: 0;
       padding-left: 0;
	   
	   margin: 5px;
  
   }
     
	 #sidebar ul h3 {
       margin-top: 25px;
       font-size: 16px;
       padding-bottom: 10px;
       border-bottom: 1px solid #ccc;
     }
     #sidebar li {
       list-style-type: none;
     }
     #sidebar ul.links li {
       margin-bottom: 5px;
     }
     
     #search {
       margin: 0;
       padding-top: 10px;
       padding-bottom: 10px;
       font-size: 11px;
     }
     #search input {
       font-size: 11px;
       margin: 2px;
     }
     #search-text {width: 170px}     


     #content {
       float: left;
       background-color: white;
       border: 3px solid #aaa;
       padding: 15px;
       width: 600px;
     }

	#footer {
        clear: both;
        padding: 15px;
      }
   </style>
</head>
<body>
  <div id="page">
	<div id="header-right">
	  <%= link_to image_tag('/images/logo-sepia.jpg', :alt=>"Home", :width=> 88, :height=>56, :border =>0),:controller => 'home',
      :action => 'index' %>
    Welcome back <%= session[:current_user].username %> &nbsp; | &nbsp; 
    <%= link_to('Log-out', :controller => 'session', :action => 'logout') %>
  </div>
	<div id="sidebar">
	  <% if session[:sprint] %>
		<div id="about-content" style="display: blocks">
	      <ul id="sidebar-items">		  
	        <li>
	          <h3><%=session[:sprint].name%></h3>
	          <ul class="links">
	            <li><%= link_to('Home', :controller => 'home', :action => 'index') %>		              
                <li><%= link_to('Sync Tasks', :controller => 'tasks', :action => 'sync_with_tickets', :sprint_id=>session[:sprint].id) %>
                <li><%= link_to('Tasks', :controller => 'tasks', :action => 'list') %>
	            <li><%= link_to('Edit Initial Estimates', :controller => 'home', :action => 'index', :edit_initial_estimates=>'1') %>
                <li><%= link_to('Estimates', :controller => 'estimates', :action => 'list', :sprint_id => session[:sprint].id) %>
		            <li><%= link_to('Calendar', :controller => 'home', :action => 'calendar_details') %>
              </ul>
	        </li>	
	        <li>
			  <h3>Summary</h3>
		      <%= numeric_date(session[:sprint].start_date) %> - <%= numeric_date(session[:sprint].stop_date) %>
			  <table cellspacing="0" cellpadding="0" border="0"
	          	        style="margin-right: 0px; ">
	  	        <tr class="even_row">
	          	<td><strong>Status</strong></td>
	          	<td align="right"><%= session[:sprint].status %></td>
	          	</tr>
	          	<tr class="even_row">
	          	<td><strong>Sprint Length</strong></td>
	          	<td align="right"><nobr><%= session[:sprint].number_of_days %> days</nobr></td>
	          	</tr>
	          	<tr class="odd_row">
	          	<td><strong>Hours Total:</strong></td>
	          	<td align="right"><%= session[:sprint].tasks.total_hours %></td>
	          	</tr>
	            <% if session[:sprint].start_date <= Date.today and  (session[:sprint].stop_date + 1) > Date.today %>
	          	  <% if (session[:sprint].stop_date + 1) > Date.today %>

	          	<tr class="even_row">
	          	<td><strong>Time Remaining:</strong></td>
	          	<td align="right">
	          	  <nobr>
	          	<%= distance_of_time_in_words(Time.now,
	          	                              Time.parse((session[:sprint].stop_date + 1).to_s)) %>
	          	  </nobr>
	          	</td>
	          	</tr>
	          	<tr class="odd_row">
	          	<td><strong>Hours Remaining:</strong></td>
	          	<td align="right"> <%= session[:sprint].tasks.hours_left %></td>
	          	</tr>
	          	  <% end %>
	          	<% end %>
	          </table>
		    </li>
	        <li>
			  <div id="calender">
				<% session[:sprint].months_sprint_belongs_in.each do |sprintmonth| %>
				<%= calendar({:year => sprintmonth.year, :month => sprintmonth.month, :abbrev => (0..0), :table_class => "calender"}) do |d|
				    cell_text = "#{d.mday}" 
  				    cell_attrs = {:class => 'day'}
				    if session[:sprint].active?(d)
				      #cell_text << 'A'
				      cell_attrs[:class] = 'sprint_active'
				    end
				    if Time.today.day ==d.day
					  cell_attrs[:class] = 'sprint_today'
					end
				
				  #Estimate.find(:all).each do |e|
				  #  if e.date == d
				  ##    cell_text << e.id
				   #   cell_attrs[:class] = 'specialDay'
				   # end
				  #end
				    [cell_text, cell_attrs]
				  end
				%>	
				<% end %>		
			  </div>
		    </li>	
	      </ul>
		</div>	  
		<p/>
	  <% end %>
		<div id="about-content" style="display: blocks">
			<ul id="sidebar-items">
        <li>
          
      
          <%= start_form_tag(:controller => 'sprints', :action => 'select_sprint') %>
            <div class="form-element">
              <%= select 'sprint', 'id' , Sprint.find(:all, :order => "start_date asc").collect {|s| [ s.name, s.id ] } %>
            </div>
            <input type="submit" value="Select" /> this sprint
          <%= end_form_tag %>
        </li>			  
				  <li>
		            <h3>Sync with Trac</h3>
		            <ul class="links">
		              <li><%= link_to('Sync Sprints', :controller => 'sprints', :action => 'sync_with_milestones') %>
		              <li><%= link_to('Sync Users', :controller => 'users', :action => 'sync_from_tickets') %>
		            </ul>
		          </li>	
				  <li>
		            <h3>Manage</h3>
		            <ul class="links">
		              <li><%= link_to('Sprints', :controller => 'sprints', :action => 'list') %>
		              <li><%= link_to('Users', :controller => 'users', :action => 'list') %>
		            </ul>
		          </li>			
			</ul>
		</div>
	</div>
	<div id="content">
<%= @content_for_layout %>
	</div>
	
	<div id="footer">
	<h5>
		Developed by <a href="http://www.opensourceconnections.com">OpenSource Connections</a>.  Copyright 2006.
	</h5>
	</div>
	</div>
</body>
</html>
